<template>
    <div>
        <h3>文件上传页面</h3>
        <form>
            file：<input ref="file" type="file" name="photo">
            <button type="button" @click="upload">上传</button>
        </form>
    </div>
</template>

<script>
import axios from '@/util/request.js';
export default {
    data() {
        return {};
    },
    methods: {
        upload() {
            let file = this.$refs.file.files[0];
            if (!file) {
                
                return;
            }
            let formData = new FormData();
            formData.append("photo", file)
            axios.post("user/upload", formData).then(r => {
                console.log(r);
            })
        }

    },
};
</script>